var app = Common.initApp(['ngAnimate']);
Common.initDirective(app);
// Pageoffice.direcPageoffice(app);
app.controller('openOfficeController', [
    '$scope', '$http', '$templateCache',
    function ($scope, $http, $templateCache) {

        $scope.openDocument = function () {
            var dataUrl = '';
            if ($scope.LX) {
                dataUrl = Common.webRoot() + '';
            } else {
                dataUrl = Common.webRoot() + "/szboanda/hbdc/gwgl/fwgl/controller/fwglworkflowmotioncontroller/getZwFileByXh";
            }
            var openDocumentConfig = {
                method: "POST",
                url: dataUrl,
                data: JSON.stringify({YWSJID: $scope.YWID, WJMC: $scope.WJMC, NEWFLAG: $scope.NEWFLAG}),
                success: function (data) {
                    $scope.WJID = data.data.WJID;
                    $scope.YWSJID = data.data.YWSJID;
                    $scope.WJMC = data.data.WJMC;
                    debugger;
                    if (data.data.PXH == "10") {
                        $scope.modeType = "3";
                    } else {
                        $scope.modeType = "2";
                    }
                    $scope.openOffice();
                }
            };
            Common.send($scope, $http, openDocumentConfig);
        };


        $scope.openOffice = function() {
            //debugger;
            var flag = Pageoffice.checkPageOffice();
            console.log(flag);
            if (flag) {
                $("#pageoffice-download-link").hide();
            } else {
                $("#pageoffice-download-link").show();
            }
            Pageoffice.openOffice($scope, $http, {
                templateId: $scope.WJID,
                ywsjId: $scope.YWSJID,
                /*beanName: 'ProjectAdapter',
                beanParams: 'obj001',*/
                fileName: $scope.WJMC,
                title: $scope.WJMC,
                modeType: $scope.modeType,
                userDefineBtns: 'buttons.history',
                showTitlebar: true,
                showSaveBtn: true,
                saveWithRevision: true,
                showAcceptRevisionBtn: true,
                showRevisionBtn: true
            });
        };
    }
]);
